home *** CD-ROM | disk | FTP | other *** search
- /*
- * WEICGlue.c
- *
- * WASTE PROJECT
- * Internet Config Glue
- *
- * Copyright (c) 1993-1997 Marco Piovanelli
- * All Rights Reserved
- *
- * C port by Dan Crevier
- *
- */
-
- #ifndef __ICAPI__
- #include "ICAPI.h"
- #endif
-
- #ifndef __ICCOMPONENTSELECTORS__
- #include "ICComponentSelectors.h"
- #endif
-
- #ifndef __COMPONENTS__
- #include <Components.h>
- #endif
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
- #ifndef __GESTALT__
- #include <Gestalt.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- // Internet Config component type and subtype
-
- enum
- {
- kICComponentType = 'PREF',
- kICComponentSubType = 'ICAp'
- };
-
- enum
- {
- uppCallComponentProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentParameters *)))
- };
-
- #if ! GENERATINGCFM
- // direct inline calls (classic 68K only)
-
- extern pascal ICError ICCStartComponent ( ICInstance instance, OSType creator )
- FIVEWORDINLINE ( 0x2F3C, 0x0004, kICCStart, 0x7000, _ComponentDispatch ) ;
- extern pascal ICError ICCStopComponent ( ICInstance instance )
- FIVEWORDINLINE ( 0x2F3C, 0x0000, kICCStop, 0x7000, _ComponentDispatch ) ;
- extern pascal ICError ICCFindConfigFile ( ICInstance instance, SInt16 count, ICDirSpecArrayPtr folders )
- FIVEWORDINLINE ( 0x2F3C, 0x0006, kICCFindConfigFile, 0x7000, _ComponentDispatch ) ;
- extern pascal ICError ICCParseURL ( ICInstance instance, ConstStr255Param hint, Ptr data, SInt32 len, SInt32 * selStart, SInt32 * selEnd, Handle url )
- FIVEWORDINLINE ( 0x2F3C, 0x0018, kICCParseURL, 0x7000, _ComponentDispatch ) ;
- extern pascal ICError ICCLaunchURL ( ICInstance instance, ConstStr255Param hint, Ptr data, SInt32 len, SInt32 * selStart, SInt32 * selEnd )
- FIVEWORDINLINE ( 0x2F3C, 0x0014, kICCLaunchURL, 0x7000, _ComponentDispatch ) ;
- #endif // ! GENERATINGCFM
-
- pascal ICError ICStart
- (
- ICInstance * instance,
- OSType creator
- )
- {
- SInt32 response ;
- ICInstance ic ;
- ICError err ;
-
- * instance = nil ;
-
- // make sure the Component Manager is available
- if ( ( err = Gestalt ( gestaltComponentMgr, & response ) ) != noErr )
- {
- goto cleanup ;
- }
-
- // connect to Internet Config
- if ( ( ic = ( ICInstance ) OpenDefaultComponent ( kICComponentType, kICComponentSubType ) ) == nil )
- {
- err = unimpErr ;
- goto cleanup ;
- }
-
- // start Internet Config
- #if GENERATINGCFM
- {
- struct
- {
- UInt8 flags ;
- UInt8 paramSize ;
- SInt16 what ;
- OSType creator ;
- ICInstance instance ;
- } params ;
- params . flags = 0 ;
- params . paramSize = sizeof ( creator ) ;
- params . what = kICCStart ;
- params . creator = creator ;
- params . instance = ic ;
- err = CallUniversalProc ( CallComponentUPP, uppCallComponentProcInfo, & params ) ;
- }
- #else
- err = ICCStartComponent ( ic, creator ) ;
- #endif
-
- if ( err != noErr )
- {
- CloseComponent ( ( ComponentInstance ) ic ) ;
- goto cleanup ;
- }
-
- // return IC instance
- * instance = ic ;
-
- // clear result code
- err = noErr ;
-
- cleanup :
- return err ;
- }
-
- pascal ICError ICStop
- (
- ICInstance instance
- )
- {
- // stop Internet Config
- #if GENERATINGCFM
- struct
- {
- UInt8 flags ;
- UInt8 paramSize ;
- SInt16 what ;
- ICInstance instance ;
- } params ;
- params . flags = 0 ;
- params . paramSize = 0 ;
- params . what = kICCStop ;
- params . instance = instance ;
- CallUniversalProc ( CallComponentUPP, uppCallComponentProcInfo, & params ) ;
- #else
- ICCStopComponent ( instance ) ;
- #endif
-
- // and release the component instance
- CloseComponent ( ( ComponentInstance ) instance ) ;
-
- return noErr ;
- }
-
- pascal ICError ICFindConfigFile
- (
- ICInstance instance,
- SInt16 count,
- ICDirSpecArrayPtr folders
- )
- {
- #if GENERATINGCFM
- struct
- {
- UInt8 flags ;
- UInt8 paramSize ;
- SInt16 what ;
- void * folders ;
- SInt16 count ;
- ICInstance instance ;
- } params ;
- params . flags = 0 ;
- params . paramSize = sizeof ( count ) + sizeof ( folders ) ;
- params . what = kICCFindConfigFile ;
- params . folders = folders ;
- params . count = count ;
- params . instance = instance ;
- return CallUniversalProc ( CallComponentUPP, uppCallComponentProcInfo, & params ) ;
- #else
- return ICCFindConfigFile ( instance, count, folders ) ;
- #endif
- }
-
- pascal ICError ICParseURL
- (
- ICInstance instance,
- ConstStr255Param hint,
- Ptr data,
- SInt32 len,
- SInt32 * selStart,
- SInt32 * selEnd,
- Handle url
- )
- {
- #if GENERATINGCFM
- struct
- {
- UInt8 flags ;
- UInt8 paramSize ;
- SInt16 what ;
- Handle url ;
- SInt32 * selEnd ;
- SInt32 * selStart ;
- SInt32 len ;
- Ptr data ;
- ConstStr255Param hint ;
- ICInstance instance ;
- } params ;
- params . flags = 0 ;
- params . paramSize = sizeof ( hint ) + sizeof ( data ) + sizeof (len ) +
- sizeof ( selStart ) + sizeof ( selEnd ) + sizeof ( url ) ;
- params . what = kICCParseURL ;
- params . url = url ;
- params . selEnd = selEnd ;
- params . selStart = selStart ;
- params . len = len ;
- params . data = data ;
- params . hint = hint ;
- params . instance = instance ;
- return CallUniversalProc ( CallComponentUPP, uppCallComponentProcInfo, & params ) ;
- #else
- return ICCParseURL ( instance, hint, data, len, selStart, selEnd, url ) ;
- #endif
- }
-
- pascal ICError ICLaunchURL
- (
- ICInstance instance,
- ConstStr255Param hint,
- Ptr data,
- SInt32 len,
- SInt32 * selStart,
- SInt32 * selEnd
- )
- {
- #if GENERATINGCFM
- struct
- {
- UInt8 flags ;
- UInt8 paramSize ;
- SInt16 what ;
- SInt32 * selEnd ;
- SInt32 * selStart ;
- SInt32 len ;
- Ptr data ;
- ConstStr255Param hint ;
- ICInstance instance ;
- } params ;
- params . flags = 0 ;
- params . paramSize = sizeof ( hint ) + sizeof ( data ) + sizeof (len ) +
- sizeof ( selStart ) + sizeof ( selEnd ) ;
- params . what = kICCLaunchURL ;
- params . selEnd = selEnd ;
- params . selStart = selStart ;
- params . len = len ;
- params . data = data ;
- params . hint = hint ;
- params . instance = instance ;
- return CallUniversalProc ( CallComponentUPP, uppCallComponentProcInfo, & params ) ;
- #else
- return ICCLaunchURL ( instance, hint, data, len, selStart, selEnd ) ;
- #endif
- }
-